<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      th:replace="~{layout/base :: html(content=~{::content})}">
<body>
    <th:block th:fragment="content">
        <div class="container mt-4">
            <div class="row justify-content-center">
                <div class="col-md-8">
                    <div class="card">
                        <div class="card-header">
                            <h3 class="card-title mb-0" th:text="${listing.listingId == null ? '添加网约车' : '编辑网约车'}">车辆表单</h3>
                        </div>
                        <div class="card-body">
                            <form th:action="@{/listings/save}" method="post" th:object="${listing}">
                                <input type="hidden" th:field="*{listingId}">
                                
                                <div class="form-group">
                                    <label for="title">标题</label>
                                    <input type="text" class="form-control" id="title" th:field="*{title}" required>
                                </div>

                                <div class="form-group">
                                    <label for="location">区域</label>
                                    <select class="form-control" id="location" th:field="*{location}" required>
                                        <option value="">请选择区域</option>
                                        <option th:each="district : ${districts}" 
                                                th:value="${district}" 
                                                th:text="${district}">区域</option>
                                    </select>
                                </div>

                                <div class="form-row">
                                    <div class="form-group col-md-4">
                                        <label for="price">价格</label>
                                        <div class="input-group">
                                            <div class="input-group-prepend">
                                                <span class="input-group-text">¥</span>
                                            </div>
                                            <input type="number" class="form-control" id="price" th:field="*{price}" 
                                                   min="0" step="0.01" required>
                                        </div>
                                    </div>
                                    <div class="form-group col-md-4">
                                        <label for="area">面积（平方米）</label>
                                        <input type="number" class="form-control" id="area" th:field="*{area}" 
                                               min="1" step="0.01" required>
                                    </div>
                                    <div class="form-group col-md-4">
                                        <label for="rating">评分</label>
                                        <input type="number" class="form-control" id="rating" th:field="*{rating}" 
                                               min="1" max="5" step="0.1">
                                    </div>
                                </div>

                                <div class="form-row">
                                    <div class="form-group col-md-6">
                                        <label for="roomType">车辆</label>
                                        <select class="form-control" id="roomType" th:field="*{roomType}" required>
                                            <option value="">请选择车型</option>
                                            <option value="经济型">经济型</option>
                                            <option value="中高端商务">舒适型</option>
                                            <option value="豪华商务座驾">豪华型</option>
                                            <option value="越野性能好">SUV</option>
                                            <option value="纯电动">新能源</option>
                                        </select>
                                    </div>
                                    <div class="form-group col-md-6">
                                        <label for="reviewsCount">评价数量</label>
                                        <input type="number" class="form-control" id="reviewsCount" th:field="*{reviewsCount}" 
                                               min="0">
                                    </div>
                                </div>

                                <div class="form-row">
                                    <div class="form-group col-md-6">
                                        <label for="hostName">司机姓名</label>
                                        <input type="text" class="form-control" id="hostName" th:field="*{hostName}">
                                    </div>
                                    <div class="form-group col-md-6">
                                        <label for="hostResponseRate">司机响应率</label>
                                        <div class="input-group">
                                            <input type="text" class="form-control" id="hostResponseRate" 
                                                   th:field="*{hostResponseRate}" placeholder="例如：95%">
                                            <div class="input-group-append">
                                                <span class="input-group-text">%</span>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label for="description">描述</label>
                                    <textarea class="form-control" id="description" th:field="*{description}" 
                                              rows="3"></textarea>
                                </div>

                                <div class="form-group">
                                    <div class="custom-control custom-checkbox">
                                        <input type="checkbox" class="custom-control-input" id="isSuperHost" 
                                               th:field="*{isSuperHost}">
                                        <label class="custom-control-label" for="isSuperHost">超级司机</label>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label>状态</label>
                                    <div class="custom-control custom-radio">
                                        <input type="radio" id="statusActive" name="status" th:field="*{status}" 
                                               value="1" class="custom-control-input">
                                        <label class="custom-control-label" for="statusActive">上架</label>
                                    </div>
                                    <div class="custom-control custom-radio">
                                        <input type="radio" id="statusInactive" name="status" th:field="*{status}" 
                                               value="0" class="custom-control-input">
                                        <label class="custom-control-label" for="statusInactive">下架</label>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <button type="submit" class="btn btn-primary">保存</button>
                                    <a th:href="@{/listings}" class="btn btn-secondary ml-2">返回</a>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </th:block>
</body>
</html> 